import java.util.ArrayList;

public class State
{
	public Mal malStang;
	public Mal malDrept;
	
	public State(Mal malStang, Mal malDrept)
	{
		this.malStang = new Mal(malStang);
		this.malDrept = new Mal(malDrept);
	}
	
	public boolean equals(State s) {
		if (s.malDrept.equals(this.malDrept) && s.malStang.equals(this.malStang))
			return true;
		return false;
	}
	
	public ArrayList<State> expand() {
		ArrayList<State> states = new ArrayList<State>();
		Mal malStang = new Mal(this.malStang);
		Mal malDrept = new Mal(this.malDrept);
		
		malStang.mutaBarca();
		malDrept.mutaBarca();
		
		if (malStang.inConflict())
		{
			if (malStang.getVarza() == 1)
			{
				malStang.mutaVarza();
				malDrept.mutaVarza();
				states.add(new State(malStang, malDrept));
			}
		
			malStang = new Mal(this.malStang);
			malDrept = new Mal(this.malDrept);
			
			if (malStang.getCapra() == 1)
			{
				malStang.mutaCapra();
				malDrept.mutaCapra();
				states.add(new State(malStang, malDrept));
			}
				
			malStang = new Mal(this.malStang);
			malDrept = new Mal(this.malDrept);
			
			if (malStang.getLup() == 1)
			{
				malStang.mutaLup();
				malDrept.mutaLup();
				states.add(new State(malStang, malDrept));
			}
		}
		else
		{
			if (malDrept.getVarza() == 1)
			{
				malStang.mutaVarza();
				malDrept.mutaVarza();
				states.add(new State(malStang, malDrept));
			}
		
			malStang = new Mal(this.malStang);
			malDrept = new Mal(this.malDrept);
			
			if (malDrept.getCapra() == 1)
			{
				malStang.mutaCapra();
				malDrept.mutaCapra();
				states.add(new State(malStang, malDrept));
			}
				
			malStang = new Mal(this.malStang);
			malDrept = new Mal(this.malDrept);
			
			if (malDrept.getLup() == 1)
			{
				malStang.mutaLup();
				malDrept.mutaLup();
				states.add(new State(malStang, malDrept));
			}
		}
		
		return states;
	}
	
	public String toString() {
		return "" + malStang + " : " + malDrept;
	}
}